package cs6238.test;

import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;

/**
 * This is used for capturing output to the console during unit tests
 *
 */
public class MockConsoleOut extends PrintStream{

	private ArrayList<String> lines = new ArrayList<String>();
	
	public MockConsoleOut(OutputStream arg0) {
		super(arg0);
	}
	
	@Override
	public void println(String value){
		lines.add(value);
	}
	
	@Override
	public void println(Object value){
		lines.add(value.toString());
	}
	
	public boolean hasLineContainingText(String text){
		for(String line : lines){
			if(line.contains(text)){
				return true;
			}
		}
		
		return false;
	}
}
